package com.tencreat.mall.controller.app;


import com.tencreat.common.constant.MallConstants;
import com.tencreat.common.core.HttpResult;
import com.tencreat.domain.mall.MallMaterial;
import com.tencreat.service.mall.IMallMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags="99-朋友圈素材api")
@RestController
@RequestMapping("/api/material")
public class MallMaterialController {
    @Autowired
    private IMallMaterialService mallMaterialService;
    /**
     * 查询朋友圈素材列表
     */
    @ApiOperation(value="查询朋友圈素材列表")
    @PostMapping("/list")
    public HttpResult<List<MallMaterial>> list() {
        List<MallMaterial> list = mallMaterialService.lambdaQuery().eq(MallMaterial::getState, MallConstants.MALL_STATE_UP)
                .orderByDesc(MallMaterial::getTop).orderByAsc(MallMaterial::getSort).orderByDesc(MallMaterial::getCreateTime).list();
        return HttpResult.ok(list);
    }
}
